package chpt08;

import java.io.PipedInputStream;

public class Receiver implements Runnable{
    PipedInputStream in;
    public Receiver(PipedInputStream in){
        this.in = in;
	}
    public void run(){
		byte[] buf = new byte[256];
		int i=0;
        try {
            while (i<3) {
                int len = in.read(buf,0,256);
                if (len != 0) {
					System.out.print("Message received:");
                    System.out.println(new String(buf,0,len));
                }
                i++;
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}